package com.example.medicine.Mapper;


import com.example.medicine.Bean.mingyi;
import org.apache.ibatis.annotations.*;

import java.util.List;


@Mapper
public interface myxxMapper {
    @Select("select * from [mingyi]")
    List<mingyi> getall();
    @Select("select * from [mingyi] where id=#{id}")
    mingyi getById(int id);

    @Insert("insert into [mingyi](xingming,chaodai,jiguan,xinyididian,yijialiupai,tedian,shicheng,dizi,suoshuoqihou,shenhe,createuser) " +
            "values(#{xingming},#{chaodai},#{jiguan},#{xinyididian},#{yijialiupai},#{tedian},#{shicheng},#{dizi},#{suoshuoqihou},#{shenhe},#{createuser})")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void insert(mingyi mingyi);

    // 添加批量插入方法，注意使用 @Param 注解传递 List
    @Insert("<script>INSERT INTO [mingyi] (xingming, chaodai, jiguan, xinyididian, yijialiupai, tedian, shicheng, dizi, suoshuoqihou, shenhe, createuser) VALUES " +
            "<foreach collection='list' item='item' separator=','>" +
            "(#{item.xingming}, #{item.chaodai}, #{item.jiguan}, #{item.xinyididian}, #{item.yijialiupai}, #{item.tedian}, #{item.shicheng}, #{item.dizi}, #{item.suoshuoqihou}, #{item.shenhe}, #{item.createuser})" +
            "</foreach></script>")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    void batchInsertDataList(@Param("list") List<mingyi> dataList);

    @Update("update [mingyi] set xingming=#{xingming},chaodai=#{chaodai},jiguan=#{jiguan},xinyididian=#{xinyididian},yijialiupai=#{yijialiupai},tedian=#{tedian},shicheng=#{shicheng},dizi=#{dizi},suoshuoqihou=#{suoshuoqihou} where id=#{id}")
    void update(mingyi mingyi);

    @Update("update [mingyi] set shenhe=#{shenhe},shr=#{shr},shsj=GETDATE() where id=#{id}")
    void updateShenhe(mingyi mingyi);

    @Delete("delete from [mingyi] where id=#{id}")
    void deleteById(int id);
}
